function sum(...nums) {
    return nums.reduce((prevoius, current) => prevoius + current, 0)
}
console.log(sum(1, 2, 3));
console.log(sum(1, 2, 3, 4));

function convertCurrency(rate, ...amounts) {
    return amounts.map(amount => amount * rate)
}

const amounts = convertCurrency(0.89, 20, 12, 89, 34)
console.log(amounts)

const player = ['jean', 1234, 10, 9, 9, 10]
const [name, id, ...score] = player
console.log(name, id, score);

const youngers = ['George', 'John', 'Thomas']
const olders = ['James', 'Adrew', 'Martin']
let menbers = [...youngers, 'Mary', ...olders]
console.log(menbers);

const todos = [...document.querySelectorAll('li')]
const li = todos.map(todo => todo.textContent)
console.log(li);

const favorites = {
    colors: ['white', 'black'],
    fruits: ['banana', 'apple']
}
const shoppingList = ['milk', 'swites', ...favorites.fruits]
console.log(shoppingList)

const tasks = [
    { id: 1, name: 'go to store', conpleted: false },
    { id: 2, name: 'watch tv', conpleted: true },
    { id: 3, name: 'ho shopping', conpleted: false }
]

const taskId = 2;
const taskIndex = tasks.findIndex(task => task.id === taskId)
const newTasks = [...tasks.slice(0, taskIndex), ...tasks.slice(taskIndex + 1)]
console.log(newTasks);

const website = 'laravist'
const age = 2
const date = '2019-06-18'
const Laravist = {
    website, age, date,
    greet() {
        console.log(`hello ${this.website}`)
    }
}
console.log(Laravist);
Laravist.greet()

let userId = 0;
const userIds = {
    [`user-${++userId}`]: userId,
    [`user-${++userId}`]: userId,
    [`user-${++userId}`]: userId
}
console.log(userIds)

const keys = ['name', 'age', 'birthday']
const values = ['jean', '16', '2003-06-01']
const Jean = {
    [keys.shift()]: values.shift(),
    [keys.shift()]: values.shift(),
    [keys.shift()]: values.shift()
}
console.log(Jean)